# _*_ coding: utf-8 _*_

# @File    :   外观模式.py
# @Version :   xxx
# @Author  :   grit
# @Email   :   2285839445@qq.com
# @Time    :   2020/08/23 12:04:51
# Description:

import abc

# 组件类
class Amplifier:
    def on(self):
        print("扩音器开")

    def off(self):
        print("扩音器关")

class Tuner:
    def on(self):
        print("调音器开")
    
    def off(self):
        print("调音器关")


class Screen:
    def on(self):
        print("屏幕开")

    def off(self):
        print("屏幕关")

class DVDPlayer:
    def on(self):
        print("DVD播放器开")

    def off(self):
        print("DVD播放器关")

# 外观类:家庭影院
class HomeTheaterFacade:

    def __init__(self,amplifier,tuner,screen,DVDplayer):
        self.amplifier = amplifier
        self.tuner = tuner
        self.screen = screen
        self.DVDplayer = DVDplayer


    def watch_movie(self):

        self.amplifier.on()
        self.tuner.on()
        self.DVDplayer.on()
        self.screen.on()

    def end_movie(self):

        self.amplifier.off()
        self.tuner.off()
        self.DVDplayer.off()
        self.screen.off()

# 客户端代码
def main():
    # 生成组件
    amplifier = Amplifier()
    tuner = Tuner()
    DVDplayer = DVDPlayer()
    screen = Screen()
    # 客户只需要与一个类打交道就好了
    home_theaterFacade = HomeTheaterFacade(amplifier,tuner,screen, DVDplayer)
    home_theaterFacade.watch_movie()
    home_theaterFacade.end_movie()
    pass


if __name__ == "__main__":
    main()
